<template>
	<view>
		<view class="list_box">
			<view class="list" @tap="editpsd()">
				<view>密码修改</view>
				<view>></view>
			</view>
			<view class="list" @tap="siteinfo()">
				<view>消息通知</view>
				<view>></view>
			</view>
			<!-- <view class="list">
				<view>站内信</view>
				<view>></view>
			</view> -->
		</view>
		<view style="width:750upx;height:15upx;background-color:#f4f4f4;"></view>
		<view class="list_box">
			<view class="list" @click="download()">
				<view>APP下载</view>
				<view>
					<view style="color: #999999;">{{baseUrl}}/download/gy{{app_version}}.apk</view>
					<!-- <text style="height:50upx;background-color:#ef5f2d;border-radius:25upx;line-height:50upx;padding:0 15upx 4upx;text-align:center;color:#FFFFFF;font-size:20upx;margin-right:20upx;">NEW</text> -->
					<!-- > -->
				</view>
			</view>
			<!-- <view class="list">
				<view>关于</view>
				<view>></view>
			</view> -->
		</view>
		<view class="loginout" @click="loginout()">
			<view>退出登录</view>
		</view>
	</view>
</template>

<script>
	import request from '@/common/lib/request.js'
	import h5Copy from '@/js_sdk/junyi-h5-copy/junyi-h5-copy/junyi-h5-copy.js'
	export default {
		data() {
			return {
				baseUrl:request.common.baseUrl,
				app_version:0
			}
		},
		onLoad: function (option)  {
			uni.request({
				url: request.common.baseUrl+'/api/index/systemSet',
				data: {},
				header: {
					'Content-Type':'application/json;charset=UTF-8',
					'Content-Type':'application/x-www-form-urlencoded'
				},
				success: (res) => {
					if(res.data.code==200){
						this.app_version=res.data.app_version
					}
				}
			});
		},
		methods: {
			editpsd(){
				uni.navigateTo({
					url:'/pages/login/editpsd'
				})
			},
			loginout(){
				uni.removeStorage({
				    key: 'keyToken',
				    success: function (res) {
				        uni.reLaunch({
				            url: '/pages/index/index'
				        });
				    }
				});
			},
			siteinfo(){
				uni.navigateTo({
					url:'/pages/score/siteinfo'
				})
			},
			download(){
				var that = this
				if(this.app_version>0){
					// window.location.href=request.common.baseUrl+'/download/gy'+this.app_version+'.apk'
					let text = String(request.common.baseUrl+'/download/gy'+this.app_version+'.apk') // 复制内容，必须字符串，数字需要转换为字符串
					const result = h5Copy(text)
					if (result === false) {
						uni.showToast({
							title:'不支持',
							icon:'none'
						})
					} else {
						uni.showToast({
							title:'复制成功,请在浏览器中打开',
							icon:'none'
						})
					}
					// const downloadTask = uni.downloadFile({
					//     url:  request.common.baseUrl+'/download/gy'+this.app_version+'.apk', //仅为示例，并非真实的资源
					//     success: (res) => {
					//         if (res.statusCode === 200) {
					//             console.log('下载成功');
					// 			// h5不支持保存本地
					// 			// uni.saveFile({  
					// 			//    tempFilePath: res.tempFilePath,  
					// 			//    complete(resc) {  
					// 			// 	 console.log(resc)  
					// 			//    }  
					// 			// });
					//         }
					//     }
					// });
					
					// downloadTask.onProgressUpdate((res) => {
					// 	uni.showToast({
					// 		icon:none,
					// 		title:res.progress+'%',
					// 		duration:1000
					// 	})
					// });
				}
				
			}
		}
	}
</script>

<style>
page{
	background-color: #ffffff;
}
.list_box{
	width:700upx;
	margin:0 25upx;
}
.list{
	width:700upx;
	height:100upx;
	border-bottom:1upx solid #f6f6f6;
}
.list view:nth-child(1){
	float:left;
	height:100upx;
	line-height:100upx;
}
.list view:nth-child(2){
	float:right;
	height:100upx;
	line-height:100upx;
}
.loginout{
	margin-top:80upx;
	text-align:center;
}
.loginout view{
	background-color:#ebebeb;
	color:#666666;
	font-size:28upx;
	width:650upx;
	height:80upx;
	line-height:80upx;
	margin:auto;
	border-radius:40upx;
}

</style>
